<template>
  <div class="c-ph24 c-pt40 c-pb30 c-bd-b1" v-if="themeName == 'mb5' && !isMicroPage">
    <div class="c-flex-row c-aligni-center">
      <span class="c-fs30">{{mutuaTitles}}</span>
      <span class="c-fs18 c-fc-sgray c-pt4 c-ml16 c-w0 c-flex-grow1 c-mr16 c-text-ellipsis1">{{mutuaDesc}}</span>
      <span class="c-fs20 c-fc-gray" @click="clickMoreVoice">更多</span>
    </div>
    <div class=" c-pt30 c-flex-row" v-for="(item,index) in voiceList" :key="index" @click="clickGoVoiceDetail(item.paperMainId)">
      <!--<div class=" c-pt30 c-flex-row">-->
      <div class="c-ww240 c-maxh160 c-text-hidden c-p c-br10">
        <img class="c-w100 imgCloseBig c-br10" :src="$addXossFilter(item.avatar, require('../../assets/defult270.png'))" />
        <vip-status :item="item"></vip-status>
      </div>
      <div class="c-pl20 c-w0 c-flex-grow1 c-flex-column c-justify-sb c-pb10">
        <div class="c-fs24 c-fc-xblack c-text-ellipsis2 c-lh36">{{item.name}}</div>
        <div class="c-flex-row c-aligni-end c-justify-sb">
          <div class="c-fs18 c-fc c-fc-gray" v-if="item.payType == 2 && Number(item.price) != 0">{{setIosText()}}{{item.subscribers | formatNumber}}</div>
          <div class="c-fs18 c-fc c-fc-gray" v-else>已测{{item.hasTestNum | formatNumber}}</div>
          <div class="theme-fc c-flex-row c-aligni-end" :class="item.payType == 2 ? 'c-fs24' : 'c-fs22'">
            <span v-if="item.payType == 2">{{'￥' | iosPriceFilter}}</span>{{item.payType | priceValueFilter(item.price, 77)}}
          </div>
        </div>
      </div>
    </div>
  </div>

  <div class="c-ph24 c-pt40 c-bd-b12-f5" v-else-if="themeName == 'mb4' && !isMicroPage">
    <div class="c-flex-row c-aligni-center">
      <span class="c-fs30 c-p c-lh c-pl20"><span class="c-pa theme-bd-l2 theme-bd-r2 c-h c-p-l0 c-br8 c-w0"></span>{{mutuaTitles}}</span>
      <span class="c-fs18 c-fc-sgray c-pt4 c-ml16 c-w0 c-flex-grow1 c-mr16 c-text-ellipsis1">{{mutuaDesc}}</span>
      <span class="c-fs20 c-fc-gray c-pl8" @click="clickMoreVoice">查看更多</span>
    </div>

    <div class="c-flex-row c-flexw-wrap c-justify-sb c-pb40">
      <div class="c-ww288 c-pt30" v-for="(item,index) in voiceList" :key="index" @click="clickGoVoiceDetail(item.paperMainId)">
        <div class="c-ww288 c-maxh288 c-br10 c-text-hidden c-br10 c-p">
          <img class="c-w100 imgCloseBig c-br10" :src="$addXossFilter(item.avatar, require('../../assets/defult270.png'))" />
          <vip-status :item="item"></vip-status>
        </div>
        <div class="c-fs24 c-pt12 c-text-ellipsis2">{{item.name}}</div>
        <div class="c-flex-row c-aligni-end c-pt16">
          <span class="theme-fc c-flex-row c-flex-grow1 c-w0" :class="item.payType == 2 ? 'c-fs24' : 'c-fs22'">
            <span v-if="item.payType == 2">{{'￥' | iosPriceFilter}}</span>{{item.payType | priceValueFilter(item.price, 125)}}
          </span>
          <span class="c-fs18 c-fc-gray" v-if="item.payType == 2 && Number(item.price) != 0">{{setIosText()}}{{item.subscribers | formatNumber}}</span>
          <span class="c-fs18 c-fc-gray" v-else>已测{{item.hasTestNum | formatNumber}}</span>
        </div>
      </div>
    </div>
  </div>

  <div v-else-if="themeName == 'mb3' && !isMicroPage">
    <index-three-title-com :titleName="mutuaTitles" :titleDesc="mutuaDesc" @clickMore="clickMoreVoice"></index-three-title-com>
    <div class="c-ph24 c-pb20 c-bd-b12-f5">
      <div class="c-pt24 c-flex-row" v-for="(item,index) in voiceList" :key="index" @click="clickGoVoiceDetail(item.paperMainId)">
        <div class="c-pb24">
          <div class="c-ww210 c-maxh210 c-text-hidden c-p c-br10">
            <img class="c-w100 imgCloseBig c-br10" :src="$addXossFilter(item.avatar, require('../../assets/defult270.png'))" />
            <vip-status :item="item"></vip-status>
          </div>
        </div>
        <div class="c-ml20 c-w0 c-flex-grow1 c-flex-column c-justify-sb c-pb24" :class="index==voiceList.length-1?'':'c-bd-b1'">
          <div class="c-fs24 c-fc-xblack c-text-ellipsis2 c-lh36">{{item.name}}</div>
          <div class="c-flex-row c-aligni-end c-justify-sb">
            <div class="theme-fc" :class="item.payType == 2 ? 'c-fs24' : 'c-fs22'">
              <span v-if="item.payType == 2">{{'￥' | iosPriceFilter}}</span>{{item.payType | priceValueFilter(item.price, 125)}}
            </div>
            <div class="c-fs18 c-fc c-fc-gray" v-if="item.payType == 2 && Number(item.price) != 0">{{setIosText()}}{{item.subscribers | formatNumber}}</div>
            <div class="c-fs18 c-fc c-fc-gray" v-else>已测{{item.hasTestNum | formatNumber}}</div>
          </div>
        </div>
      </div>
    </div>

  </div>

  <div class="c-ph24 c-pt24 c-pb24 c-mt12 c-bg-white" v-else-if="themeName == 'mb6' && !isMicroPage">
    <div class="c-flex-row c-aligni-end c-mb10">
      <span class="c-fs28 c-fw-b">{{mutuaTitles}}</span>
      <span class="c-fs20 c-fc-gray c-mb2 c-ml16 c-w0 c-flex-grow1 c-mr16 c-text-ellipsis1">{{mutuaDesc}}</span>
      <span class="c-fs18 c-fc-gray" @click="clickMoreVoice">查看更多</span>
    </div>
    <div class="c-pt24 c-flex-row" v-for="(item,index) in voiceList" :key="index" @click="clickGoVoiceDetail(item.paperMainId)">
      <div class="c-pb24">
        <div class="c-ww160 c-maxh106 c-text-hidden c-br10 c-p">
          <img class="c-w100 imgCloseBig c-br10" :src="$addXossFilter(item.avatar, require('../../assets/defult270.png'))" />
          <vip-status :item="item"></vip-status>
        </div>
      </div>
      <div class="c-pl20 c-w0 c-flex-grow1 c-flex-column c-justify-sb c-pb24" :class="index == voiceList.length - 1 ? '' : 'c-bd-b1'">
        <div class="c-fs24 c-text-ellipsis2 c-fw-b c-lh36">{{item.name}}</div>
        <div class="c-flex-row c-aligni-end c-justify-sb">
          <div class="c-fs18 c-fc-gray" v-if="item.payType == 2 && Number(item.price) != 0">{{setIosText()}}{{item.subscribers | formatNumber}}</div>
          <div class="c-fs18 c-fc-gray" v-else>已测{{item.hasTestNum | formatNumber}}</div>
          <span class="theme-fc c-flex-grow1 c-textAlign-r" :class="item.payType == 2 ? 'c-fs24' : 'c-fs22'">
            <span v-if="item.payType == 2">{{'￥' | iosPriceFilter}}</span>{{item.payType | priceValueFilter(item.price, 125)}}
          </span>
        </div>
      </div>
    </div>
  </div>

</template>
<script>
import indexThreeTitleCom from "@/components/templates/common/indexThreeTitleCom.vue";
import { utilJs } from "@/utils/common.js"
import vipStatus from '@/components/templates/common/vipStatus.vue'
export default {
  name: "voiceIndexCom",
  components: {
    indexThreeTitleCom,
    vipStatus
  },
  props: {
    mutuaTitles: {
      type: String,
      default: '语音测评',
    },
    mutuaDesc: {
      type: String,
      default: '语音测评',
    },
    voiceList: {
      type: Array,
      default: () => []
    },
    isFromM7: {
      type: Boolean,
      default: false
    },
    itemType: {
      type: Number,
      default: 1, //1一行一列，2一行两列，3一行三列
    },
    showCount: {
      type: Number,
      default: 1
    },
    proType: { //产品类型，1：课程，4：专栏
      type: Number,
      default: -1,
    },
    proId: {
      type: Number,
      default: -1,
    },
    showAll: {
      type: Boolean,
      default: false
    },
    isMicroPage: {
      type: Boolean,
      default: false
    },
    showMore: {
      type: Number,
      default: 0,
    },
    visible:{
      type: Object,
      default: () => {
        return {
          priceVisible:true, // 价格、商品价格
          originalPriceVisible:true, // 划线价格
          dataVisible:true, // 商品数据、数据字段、数据
          statusVisible:true, // 状态
          forecastVisible:true, // 预告时间
          qrVisible:true, // 预告二维码
          vipVisible:true, // vip角标
        }
      },
    }
  },
  data() {
    return {
      theme: localStorage.getItem("colorName") || "mb5_default",
      themeName: localStorage.getItem("themeName") || "mb5"
    };
  },
  methods: {
    setIosText() {
      return this.$isWxAppIos() ? '已测' : '已售'
    },
    clickMore() {
      this.$emit('clickMore');
    },
    iosAppRouteChange(toPath) {
      if (utilJs.isIOSApp()) {
        window.webkit.messageHandlers.iosWechatRoute.postMessage(toPath);
      } else if (utilJs.isAndoridNewApp()) {
        let data = {
          path: toPath
        }
        window.androidWechatRoute.doAction(JSON.stringify(data))
      } else {
        this.$routerGo(this, "push", { path: toPath });
      }
    },
    clickMoreVoice() {
      let toPath = `/homePage/voiceTest/voiceTestList`;
      this.iosAppRouteChange(toPath);
    },
    clickGoVoiceDetail(testId) {
      let toPath = `/homePage/voiceTest/voiceTestDetail?paperMainId=${testId}`;
      this.iosAppRouteChange(toPath);
    }
  }
};
</script>

<style scoped>
.mb4_default .theme-bd-r2 {
  border-right: 2px solid #ff300c;
}
</style>
